package com.tanggh.action;

import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;

import com.tanggh.entity.City;
import com.tanggh.service.CityService;
import com.tanggh.util.FreemarkerUtils;
import com.tanggh.util.TemplateUtils;
import com.tanggh.util.Tools;


/**
 *@author tanggh
 */
public class IndexAction extends GenericAction{
	private static final long serialVersionUID = 1L;
	
	@Autowired
	private CityService cityService;

	@Override
	public String execute() throws Exception {
//		testTemplate();
		testSortCity();
		return SUCCESS;
	}
	
	
	public void testTemplate() {
		
		Map<Object, Object> data = new HashMap<Object, Object>();
		data.put("username", "唐高红");
		String fltName = "hello.ftl";
		String outPath = Tools.getWebRoot()+"/template/hello.html";
		
		FreemarkerUtils.out(data, fltName, outPath);
		
		System.out.println("IndexAction.testTemplate()");
	}
	
	public void testSortCity() {
		List<City> list = cityService.getSortCity();
		TemplateUtils.createLoction(list);
		System.out.println("IndexAction.testSortCity()");
	}
}
